package com.example.hackergateway.emun;

/**
 * Description：
 *
 * @Author: cw
 * CreateTime：2022-10-14
 */
public enum  HttpCodeEnum {

    OK(200, "成功"),
    BAD_REQUEST(400, "参数错误"),
    UNAUTHORIZED(401, "认证失败"),
    FORBIDDEN(403, "禁止访问"),
    SERVER_ERROR(500, "服务器错误"),
    SIGNATURE_ERROR(501, "签名错误");

    private int code;

    private String message;

    HttpCodeEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }


    public static <T extends HttpCodeEnum> String getByCode(int code){
        for(HttpCodeEnum item: HttpCodeEnum.class.getEnumConstants()){
            if(item.getCode() == code){
                return item.getMessage();
            }
        }
        return null;
    }

}
